package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.Destination;
import cn.wolfcode.luowowo.article.domain.Strategy;
import cn.wolfcode.luowowo.article.mapper.StrategyMapper;
import cn.wolfcode.luowowo.article.query.StrategyQuery;
import cn.wolfcode.luowowo.article.service.IStrategyService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by Administrator on 2019/7/8.
 */
@Service
public class StrategyServiceImpl implements IStrategyService{
    @Autowired
    private StrategyMapper strategyMapper;
    @Override
    public PageInfo query(StrategyQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Strategy> list = strategyMapper.selectForList(qo);
        return new PageInfo(list);
    }

    @Override
    public void saveOrUpdate(Strategy strategy) {
        if (strategy.getId()==null){
            strategyMapper.insert(strategy);
        }else {
            strategyMapper.updateByPrimaryKey(strategy);
        }
    }

    @Override
    public void delete(Long id) {
        strategyMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Strategy get(Long rid) {
        return strategyMapper.selectByPrimaryKey(rid);
    }

    @Override
    public List<Strategy> listAll() {
        return strategyMapper.selectAll();
    }

}
